package com.example.motioneventmodule;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;

/**
 * 自定义TextView
 */
public class MyTextView extends androidx.appcompat.widget.AppCompatTextView {
	private static final String TAG = "MyTextView";
	public MyTextView(Context context) {
		super(context);
		Log.e(TAG, "MyTextView:Context " );
	}

	@Override
	public void layout(int l, int t, int r, int b) {
		Log.e(TAG, "layout: " );
		super.layout(l, t, r, b);
	}

	@Override
	protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
		super.onLayout(changed, left, top, right, bottom);
		Log.e(TAG, "onLayout: () changed=:"+changed );
	}

	/**
	 * 重写它：可以得到子View的对象
	 */
	@Override
	protected void onFinishInflate() {
		super.onFinishInflate();
		Log.e(TAG, "onFinishInflate: " );
	}

	public MyTextView(Context context, AttributeSet attrs) {
		super(context, attrs);
		Log.e(TAG, "MyTextView: (Context,AttributeSet)");
	}

	@Override
	/**
	 * 也是为了得到子View的对象
	 */
	protected void onAttachedToWindow() {
		super.onAttachedToWindow();
		Log.e(TAG, "onAttachedToWindow: " );
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		Log.e(TAG, "onMeasure:执行了" );
		int measuredHeight = getMeasuredHeight();
		int measuredWidth = getMeasuredWidth();
		Log.e(TAG, "onMeasure: "+measuredHeight+","+measuredWidth );
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}

	public MyTextView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);


	}
}
